<template>
  <div class="modal-overlay" @click.self="close">
    <div class="modal-container">
      <div class="modal-header">
        <h3>{{ exam.paperName }} - 考试分析报告</h3>
        <div class="analysis-meta">
          <!-- <span class="status-tag" :class="{'completed': isAnalysisCompleted, 'pending': !isAnalysisCompleted}">
            {{ isAnalysisCompleted ? '分析已完成' : '分析中' }}
          </span> -->
                    <!-- <span class="update-time">更新于: {{ updatedAt }}</span> -->
                </div>
                <button class="close-btn" @click="close">
                    <i class="fas fa-times"></i>
                </button>
            </div>

      <div class="modal-body">
        <!-- 分析概览 -->
        <div class="section analysis-summary">
          <h3 class="section-title">分析概览</h3>
          <div class="overview-cards">
            <div class="overview-card">
              <div class="card-icon">
                <i class="fas fa-users"></i>
              </div>
              <div class="card-content">
                <div class="card-title">参与分析考生</div>
                <div class="card-value">{{ localAnalysis.totalStudents || 0 }}</div>
              </div>
            </div>

                        <div class="overview-card">
                            <div class="card-icon">
                                <i class="fas fa-calculator"></i>
                            </div>
                            <div class="card-content">
                                <div class="card-title">平均得分</div>
                                <div class="card-value">{{ averageScore }}</div>
                            </div>
                        </div>

                        <div class="overview-card">
                            <div class="card-icon">
                                <i class="fas fa-book-open"></i>
                            </div>
                            <div class="card-content">
                                <div class="card-title">知识点覆盖率</div>
                                <div class="card-value">{{ knowledgeCoverageRate || '--' }}</div>
                            </div>
                        </div>
                    </div>
                </div>

        <!-- 考生表现 -->
        <div class="section student-performance">
          <h3 class="section-title">考生表现</h3>
          <div class="performance-stats">
            <div class="stats-group">
              <div class="group-header">
                <h4 class="group-title">表现优异学生</h4>
                <i class="fas fa-medal"></i>
              </div>
              <div class="student-list" v-if="outstandingStudents.length">
                <div class="student-item" v-for="(student, index) in outstandingStudents" :key="index">
                  <span class="student-rank">{{ index + 1 }}</span>
                  <span class="student-id">{{ student.name }}</span>
                  <span class="student-score">{{ student.score }}分</span>
                  <span class="student-title">{{ student.title }}</span>
                </div>
              </div>
              <div class="empty-state" v-else>
                暂无数据
              </div>
            </div>

            <div class="stats-group">
              <div class="group-header">
                <h4 class="group-title">需关注学生</h4>
                <i class="fas fa-exclamation-triangle"></i>
              </div>
              <div class="student-list" v-if="needsAttentionStudents.length">
                <div class="student-item" v-for="(student,index) in needsAttentionStudents" :key="index">
                  <span class="student-id">{{ student.name }}</span>
                  <span class="student-issue">{{ student.issue }}</span>
                </div>
              </div>
              <div class="empty-state" v-else>
                暂无数据
              </div>
            </div>

            <div class="stats-group">
              <div class="group-header">
                <h4 class="group-title">有独到见解学生</h4>
                <i class="fas fa-lightbulb"></i>
              </div>
              <div class="student-list" v-if="insightfulStudents.length">
                <div class="student-item" v-for="(student,index) in insightfulStudents" :key="index">
                  <span class="student-id">{{ student.name }}</span>
                  <span class="student-insight">{{ student.insight }}</span>
                </div>
              </div>
              <div class="empty-state" v-else>
                暂无数据
              </div>
            </div>
          </div>
        </div>

                <!-- 知识点分析 -->
                <div class="section knowledge-analysis">
                    <h3 class="section-title">知识点分析</h3>

          <div class="analysis-grid">
            <!-- 题型正确率 -->
            <div class="analysis-card">
              <h4 class="card-title">题型正确率</h4>
              <div class="progress-grid">
                <div v-for="(accuracy, type) in questionTypeAccuracy" :key="type" class="progress-item">
                  <span class="item-name">{{ type }}</span>
                  <div class="progress-wrapper">
                    <div class="progress-bar-container">
                      <div class="progress-bar" :style="{
                        '--target-width': parseFloat(accuracy) + '%',
                        width: parseFloat(accuracy) + '%'
                      }"></div>

                    </div>
                    <div class="progress-value">{{ accuracy }}</div>
                  </div>

                                </div>

                            </div>
                        </div>

            <!-- 风险知识点 -->
            <div class="analysis-card risk-analysis">
              <h4 class="card-title">高失分风险知识点</h4>
              <div class="risk-list">
                <div v-for="(point, index) in highRiskPoints" :key="index" class="risk-item" :class="{
                  'risk-low': point.riskProbability < 0.3,
                  'risk-medium': point.riskProbability >= 0.3 && point.riskProbability < 0.7,
                  'risk-high': point.riskProbability >= 0.7
                }">
                  <span class="point-name">{{ point.name }}</span>
                  <span class="risk-level-tag">
                    {{
                      point.riskProbability >= 0.7
                        ? '高风险'
                        : point.riskProbability >= 0.3
                          ? '中风险'
                          : '低风险'
                    }}
                  </span>
                  <div class="risk-indicator">
                    <div class="risk-bar" :style="{ width: (point.riskProbability * 100) + '%' }"></div>
                  </div>
                  <div class="risk-percent">{{ (point.riskProbability * 100).toFixed(0) }}%</div>
                </div>
              </div>
            </div>

            <!-- 薄弱点汇总模块 -->
            <div class="analysis-card weakness-summary">
              <div class="summary-header">
                <h4 class="summary-title">薄弱点汇总</h4>
                <div class="summary-icon">
                  <i class="fas fa-chart-bar"></i>
                </div>
              </div>

              <div class="tag-group">
                <!-- 共有薄弱点 -->
                <div class="weakness-category">
                  <div class="category-header">
                    <i class="fas fa-users"></i>
                    <h5>共有薄弱点</h5>
                    <span class="tag-count">{{ sharedWeakPoints.length }}个</span>
                  </div>
                  <div class="tag-list shared-tags">
                    <span v-for="(area, index) in sharedWeakPoints" :key="index" class="tag"
                      @click="showWeaknessDetail(area)">
                      {{ area.name }}
                      <span class="tag-ping"></span>
                    </span>
                  </div>
                </div>

                <!-- 所有薄弱点 -->
                <div class="weakness-category">
                  <div class="category-header">
                    <i class="fas fa-layer-group"></i>
                    <h5>所有薄弱点</h5>
                    <span class="tag-count">{{ allWeakPoints.length }}个</span>
                  </div>
                  <div class="tag-list all-tags">
                    <span v-for="(area, index) in allWeakPoints" :key="index" class="tag"
                      @click="showWeaknessDetail(area)">
                      {{ area.name }}
                      <span class="tag-ping"></span>
                    </span>
                  </div>
                </div>
              </div>

              <div class="summary-footer">
                <i class="fas fa-info-circle"></i>
                <span>点击标签可查看详细分析</span>
              </div>
            </div>
          </div>
        </div>

        <!-- AI建议与结论 -->
        <div class="section ai-suggestions">
          <h3 class="section-title">AI建议与结论</h3>

          <div class="suggestion-grid">
            <!-- 系统总结结论 -->
            <div class="suggestion-card">
              <div class="card-header">
                <div class="card-icon">
                  <i class="fas fa-brain"></i>
                </div>
                <h4 class="card-title">系统总结结论</h4>
              </div>
              <div class="card-body">
                <vue-markdown :source="autoGeneratedConclusion || '暂无系统生成的结论'" class="markdown-content"></vue-markdown>
              </div>
            </div>

            <!-- 教学建议 -->
            <div class="suggestion-card">
              <div class="card-header">
                <div class="card-icon">
                  <i class="fas fa-chalkboard-teacher"></i>
                </div>
                <h4 class="card-title">教学建议</h4>
              </div>
              <div class="card-body">
                <vue-markdown :source="overallSuggestions || '暂无教学建议'" class="markdown-content"></vue-markdown>
              </div>
            </div>

            <!-- 推荐重点知识点 -->
            <!-- 保持HTML结构不变，仅调整内容渲染部分 -->
            <div class="suggestion-card">
              <div class="card-header">
                <div class="card-icon">
                  <i class="fas fa-brain"></i>
                </div>
                <h4 class="card-title">系统总结结论</h4>
              </div>
              <div class="card-body">
                <!-- 使用vue-markdown组件，并添加一个包裹层 -->
                <div class="markdown-container">
                  <vue-markdown :source="autoGeneratedConclusion || '暂无系统生成的结论'"
                    class="markdown-content"></vue-markdown>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>

            <div class="modal-footer">
                <button class="btn btn-primary" @click="close">
                    关闭
                </button>
                <button class="btn btn-secondary" @click="exportAnalysis" :disabled="!isAnalysisCompleted">
                    <i class="fas fa-download"></i> 导出分析报告
                </button>
            </div>
        </div>
    </div>
</template>

<script>
import VueMarkdown from 'vue-markdown';
export default {
  name: 'AnalysisModal',
  components: {
    VueMarkdown
  },
  props: {
    exam: {
      type: Object,
      required: true
    },
    analysis: {
      type: Object,
      required: true,
      default: {}
    }
  },
  data() {
    return {
      localAnalysis: { ...this.analysis } // 创建一个本地副本
    };
  },
  created() {
    // this.localAnalysis = this.getUniqueAnalysisData(this.analysis);
    // console.log("传入的analysis：", this.analysis)
    // console.log("本地analysis：", this.localAnalysis)
  },
  computed: {
    isAnalysisCompleted() {
      return false;
      // return this.localAnalysis.some(item => item.analysis_status === 1);
    },
    averageScore() {
      //   console.log("localAnalysis:", JSON.stringify(this.localAnalysis[0]))
      const item = this.localAnalysis;
      // console.log("averageScore item:", item);

      //   return item.averageScore || 0;
      if (item && item.averageScore) {
        return item.averageScore;
      }
      return 0;
    },
    knowledgeCoverageRate() {
      const item = this.localAnalysis;
      if (item && item.knowledgeCoverageRate) {
        return item.knowledgeCoverageRate;
      }
      return '--';
    },
    outstandingStudents() {
      return this.localAnalysis.outstandingStudents || [];
    },
    needsAttentionStudents() {
      return this.localAnalysis.needsAttentionStudents || [];
    },
    insightfulStudents() {
      // console.log("insightfulStudents:", this.localAnalysis.insightfulStudents);
      const item = this.localAnalysis;
      
      if (item && item.insightfulStudents) {
        return item.insightfulStudents;
      }
      
      return [];
    },
    questionTypeAccuracy() {
      const item = this.localAnalysis;
      if (item && item.questionTypeAccuracy) {
        return item.questionTypeAccuracy;
      }
      return {};
    },
    highRiskPoints() {
      const item = this.localAnalysis;
      if (item && item.highRiskKnowledgePoints) {
        // console.log("item.highRiskKnowledgePoints", item.highRiskKnowledgePoints);

        return item.highRiskKnowledgePoints;
      }
      return [];
    },
    sharedWeakPoints() {
      const item = this.localAnalysis;
      if (item && item.sharedWeakPoints) {
        return item.sharedWeakPoints;
      }
      return [];
    },
    allWeakPoints() {
      const item = this.localAnalysis;

      if (item && item.allWeakPoints) {
        return item.allWeakPoints;
      }

      return [];
    },
    autoGeneratedConclusion() {
      const item = this.localAnalysis;
      if (item && item.autoGeneratedConclusion) {
        return item.autoGeneratedConclusion;
      }
      return '暂无系统生成的结论';
    },
    overallSuggestions() {
      const item = this.localAnalysis;
      if (item && item.overallSuggestions) {
        return item.overallSuggestions;
      }
      return '暂无教学建议';
    },
    recommendedPoints() {
      const item = this.localAnalysis;
      if (item && item.recommendedFocusPoints) {
        return item.recommendedFocusPoints;
      }
      return [];
    }
  },
  methods: {
    close() {
      this.$emit('close');
    },
    // getUniqueAnalysisData(data) {
    //   // 根据 exam_id 或其他唯一标识符去重
    //   return [...new Map(data.map(item => [item.exam_id, item])).values()];
    // },
    // updateAnalysisData(newData) {
    //   this.localAnalysis = this.getUniqueAnalysisData(newData);
    // },
    formatDate(dateString) {
      if (!dateString) return '未知';
      const date = new Date(dateString);
      return date.toLocaleDateString() + ' ' + date.toLocaleTimeString();
    },
    getRiskLevelText(probability) {
      if (probability < 0.3) return '低风险';
      if (probability < 0.7) return '中风险';
      return '高风险';
    },
    exportAnalysis() {
      if (!this.isAnalysisCompleted) {
        alert('分析尚未完成，无法导出报告');
        return;
      }
      console.log('导出分析报告:', this.exam, this.localAnalysis);
      alert('分析报告导出功能将在后续版本实现');
    }
  },
  // 深度监听analysis的变化
  watch: {
    analysis: {
      handler(newValue, oldValue) {
        // this.localAnalysis = this.getUniqueAnalysisData(newValue);
        // console.log('analysis变化了', newValue, oldValue);
      },
      deep: true
    }
  }
};
</script>

<style lang="less" scoped>
@primary: #4361EE;
@primary-light: #A5B4FC;
@primary-lighter: #E0E7FF;
@secondary: #3A0CA3;
@success: #10B981;
@warning: #F59E0B;
@danger: #EF4444;
@info: #3B82F6;
@light-gray: #f8f9fa;
@dark-gray: #343a40;

@gray-50: #F9FAFB;
@gray-100: #F3F4F6;
@gray-200: #E5E7EB;
@gray-300: #D1D5DB;
@gray-400: #9CA3AF;
@gray-500: #6B7280;
@gray-600: #4B5563;
@gray-700: #374151;
@gray-800: #1F2937;
@gray-900: #111827;

@shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
@shadow-md: 0 4px 6px rgba(0, 0, 0, 0.08);
@shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
@radius-sm: 0.375rem;
@radius-md: 0.5rem;
@radius-lg: 0.75rem;
@transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
    backdrop-filter: blur(3px);
}

.modal-container {
    background-color: white;
    border-radius: @radius-md;
    width: 90%;
    max-width: 1400px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: slideUp 0.3s ease-out;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid @gray-200;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    background: linear-gradient(135deg, @primary, @secondary);
    color: white;

    h3 {
        margin: 0;
        font-size: 1.4rem;
        font-weight: 600;
        color: white;
        letter-spacing: -0.3px;
    }

    .analysis-meta {
        display: flex;
        align-items: center;
        gap: 1rem;
        font-size: 0.85rem;
        margin-top: 0.5rem;

        .status-tag {
            padding: 0.3rem 0.8rem;
            border-radius: @radius-sm;
            font-weight: 500;
            box-shadow: @shadow-sm;

            &.completed {
                background-color: rgba(255, 255, 255, 0.15);
                color: white;
                border: 1px solid rgba(255, 255, 255, 0.3);
            }

            &.pending {
                background-color: rgba(255, 255, 255, 0.15);
                color: white;
                border: 1px solid rgba(255, 255, 255, 0.3);
            }
        }

        .update-time {
            color: rgba(255, 255, 255, 0.85);
        }
    }

    .close-btn {
        background: rgba(255, 255, 255, 0.2);
        border: none;
        font-size: 1.1rem;
        color: white;
        cursor: pointer;
        padding: 0.5rem;
        border-radius: 50%;
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: @transition;

        &:hover {
            background: rgba(255, 255, 255, 0.3);
            transform: rotate(90deg);
        }
    }
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
    background: @gray-50;
}

.section {
    margin-bottom: 2.5rem;
    background: white;
    border-radius: @radius-md;
    box-shadow: @shadow-sm;
    padding: 1.5rem;
    border: 1px solid @gray-100;

    .section-title {
        margin: 0 0 1.5rem;
        font-size: 1.3rem;
        color: @gray-800;
        font-weight: 600;
        display: flex;
        align-items: center;
        padding-bottom: 0.8rem;
        border-bottom: 2px solid @primary-lighter;
        position: relative;

        &::before {
            content: '';
            width: 4px;
            height: 24px;
            background: linear-gradient(to bottom, @primary, @secondary);
            border-radius: 2px;
            margin-right: 0.75rem;
        }
    }
}

.overview-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.2rem;

    .overview-card {
        background: white;
        border-radius: @radius-md;
        padding: 1.2rem;
        display: flex;
        align-items: center;
        gap: 1.2rem;
        transition: @transition;
        box-shadow: @shadow-sm;
        border: 1px solid @gray-100;
        position: relative;
        overflow: hidden;

        &:hover {
            transform: translateY(-5px);
            box-shadow: @shadow-md;
            border-color: @primary-light;
        }

        &:before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 4px;
            background: linear-gradient(to right, @primary, @secondary);
        }

        .card-icon {
            width: 48px;
            height: 48px;
            border-radius: 50%;
            background: @primary-lighter;
            display: flex;
            align-items: center;
            justify-content: center;
            color: @primary;
            font-size: 1.4rem;
            flex-shrink: 0;
        }

        .card-content {
            flex: 1;

            .card-title {
                font-size: 0.95rem;
                color: @gray-600;
                margin-bottom: 0.4rem;
            }

            .card-value {
                font-size: 1.6rem;
                font-weight: 700;
                color: @gray-800;
                letter-spacing: -0.5px;
            }
        }
    }
}

.performance-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;

    .stats-group {
        background-color: white;
        border-radius: @radius-md;
        padding: 1.2rem;
        box-shadow: @shadow-sm;
        border: 1px solid @gray-100;
        transition: @transition;

        &:hover {
            transform: translateY(-3px);
            box-shadow: @shadow-md;
        }

        .group-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 1rem;
            padding-bottom: 0.8rem;
            border-bottom: 1px solid @gray-100;

            .group-title {
                margin: 0;
                font-size: 1.1rem;
                color: @gray-800;
                font-weight: 600;
            }

            i {
                font-size: 1.2rem;
                color: @gray-500;
            }
        }

        .student-list {
            display: flex;
            flex-direction: column;
            gap: 0.8rem;
        }

        .student-item {
            display: flex;
            align-items: center;
            padding: 0.8rem;
            background-color: @gray-50;
            border-radius: @radius-sm;
            transition: @transition;
            position: relative;
            overflow: hidden;

            &:hover {
                background-color: @primary-lighter;
                transform: translateX(5px);
            }

            &:before {
                content: '';
                position: absolute;
                left: 0;
                top: 0;
                height: 100%;
                width: 4px;
                background: @primary;
            }
        }

        .student-rank {
            background: @primary;
            color: white;
            width: 26px;
            height: 26px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.8rem;
            font-weight: 700;
            margin-right: 0.8rem;
            flex-shrink: 0;
        }

        .student-id {
            color: @gray-800;
            font-weight: 500;
            flex: 1;
        }

        .student-score {
            color: @success;
            font-weight: 600;
            margin: 0 0.8rem;
            min-width: 50px;
            text-align: right;
        }

        .student-title {
            font-size: 0.85rem;
            color: @gray-600;
            font-style: italic;
        }

        .student-issue {
            color: @danger;
            font-weight: 500;
            font-size: 0.9rem;
        }

        .student-insight {
            color: @gray-700;
            font-size: 0.9rem;
            font-style: italic;
        }

        .empty-state {
            color: @gray-500;
            font-size: 0.9rem;
            text-align: center;
            padding: 1.5rem 0;
            background: @gray-50;
            border-radius: @radius-sm;
        }
    }
}


.section.student-performance {
    margin-bottom: 2.5rem;
    background: white;
    border-radius: @radius-md;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    padding: 1.8rem;
    border: none;
    position: relative;
    overflow: hidden;

    &::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 4px;
        background: linear-gradient(90deg, #4361EE, #3A0CA3, #7209B7);
        z-index: 1;
    }

    .section-title {
        margin: 0 0 1.8rem;
        font-size: 1.35rem;
        color: @gray-800;
        font-weight: 600;
        display: flex;
        align-items: center;
        padding-bottom: 0.8rem;
        border-bottom: 1px solid rgba(67, 97, 238, 0.15);
        position: relative;

        &::before {
            content: '';
            width: 5px;
            height: 22px;
            background: linear-gradient(to bottom, #4361EE, #7209B7);
            border-radius: 3px;
            margin-right: 0.8rem;
        }
    }

    .performance-stats {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 1.8rem;

        .stats-group {
            background-color: white;
            border-radius: @radius-md;
            padding: 1.5rem;
            box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
            border: 1px solid rgba(67, 97, 238, 0.1);
            transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
            position: relative;
            overflow: hidden;

            &:hover {
                transform: translateY(-5px);
                box-shadow: 0 8px 20px rgba(67, 97, 238, 0.12);
                border-color: rgba(67, 97, 238, 0.3);
            }

            .group-header {
                display: flex;
                align-items: center;
                justify-content: space-between;
                margin-bottom: 1.2rem;
                padding-bottom: 0.8rem;
                border-bottom: 1px solid rgba(67, 97, 238, 0.1);

                .group-title {
                    margin: 0;
                    font-size: 1.15rem;
                    color: @gray-800;
                    font-weight: 600;
                    letter-spacing: -0.3px;
                }

                i {
                    font-size: 1.3rem;
                    color: #4361EE;
                    background: rgba(67, 97, 238, 0.1);
                    width: 36px;
                    height: 36px;
                    border-radius: 50%;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                }
            }

            .student-list {
                display: flex;
                flex-direction: column;
                gap: 0.8rem;
            }

            .student-item {
                display: flex;
                align-items: center;
                padding: 0.9rem 1rem;
                background-color: rgba(67, 97, 238, 0.03);
                border-radius: @radius-sm;
                transition: all 0.3s ease;
                position: relative;
                overflow: hidden;
                border: 1px solid rgba(67, 97, 238, 0.05);

                &:hover {
                    background-color: rgba(67, 97, 238, 0.08);
                    transform: translateX(5px);
                    box-shadow: 0 2px 8px rgba(67, 97, 238, 0.1);
                }

                &:before {
                    content: '';
                    position: absolute;
                    left: 0;
                    top: 0;
                    height: 100%;
                    width: 3px;
                    background: linear-gradient(to bottom, #4361EE, #7209B7);
                }
            }

            // 优异学生样式
            &:nth-child(1) {
                .group-header i {
                    color: #FFD700;
                    background: rgba(255, 215, 0, 0.1);
                }

                .student-item {
                    &:before {
                        background: linear-gradient(to bottom, #FFD700, #FFA500);
                    }
                }

                .student-rank {
                    background: linear-gradient(135deg, #FFD700, #FFA500);
                    color: white;
                    box-shadow: 0 2px 5px rgba(255, 215, 0, 0.3);
                }

                .student-score {
                    color: #FFA500;
                    font-weight: 700;
                }
            }

            // 需关注学生样式
            &:nth-child(2) {
                .group-header i {
                    color: #FF6B6B;
                    background: rgba(255, 107, 107, 0.1);
                }

                .student-item {
                    &:before {
                        background: linear-gradient(to bottom, #FF6B6B, #FF0000);
                    }
                }

                .student-issue {
                    color: #FF6B6B;
                    font-weight: 600;
                }
            }

            // 独到见解学生样式
            &:nth-child(3) {
                .group-header i {
                    color: #4ECDC4;
                    background: rgba(78, 205, 196, 0.1);
                }

                .student-item {
                    &:before {
                        background: linear-gradient(to bottom, #4ECDC4, #1A7F75);
                    }
                }

                .student-insight {
                    color: #1A7F75;
                    font-weight: 500;
                }
            }

            .student-rank {
                background: #4361EE;
                color: white;
                width: 28px;
                height: 28px;
                border-radius: 50%;
                display: flex;
                align-items: center;
                justify-content: center;
                font-size: 0.85rem;
                font-weight: 700;
                margin-right: 0.8rem;
                flex-shrink: 0;
            }

            .student-id {
                color: @gray-800;
                font-weight: 500;
                flex: 1;
                font-size: 0.95rem;
            }

            .student-score {
                color: #4361EE;
                font-weight: 600;
                margin: 0 0.8rem;
                min-width: 50px;
                text-align: right;
                font-size: 0.95rem;
            }

            .student-title {
                font-size: 0.85rem;
                color: @gray-600;
                font-style: italic;
                background: rgba(67, 97, 238, 0.08);
                padding: 0.2rem 0.5rem;
                border-radius: 4px;
            }

            .student-issue {
                color: #FF6B6B;
                font-weight: 500;
                font-size: 0.9rem;
                flex: 1;
                text-align: right;
            }

            .student-insight {
                color: #1A7F75;
                font-size: 0.9rem;
                font-style: italic;
                flex: 1;
            }

            .empty-state {
                color: @gray-500;
                font-size: 0.9rem;
                text-align: center;
                padding: 1.8rem 0;
                background: rgba(67, 97, 238, 0.03);
                border-radius: @radius-sm;
                border: 1px dashed rgba(67, 97, 238, 0.2);
                margin-top: 0.5rem;

                &:before {
                    content: "暂无数据";
                    display: block;
                    margin-bottom: 0.5rem;
                    font-size: 1.1rem;
                }
            }
        }
    }
}


.analysis-grid {
    display: grid;
    // grid-template-columns: repeat(auto-fit, minmax(min(50%, 300px), 1fr));

    grid-template-columns: 1fr 1fr;
    /* 直接分成两半 */

    gap: 1.5rem;

    .analysis-card {
        background: white;
        border-radius: @radius-md;
        padding: 1.5rem;
        box-shadow: @shadow-sm;
        border: 1px solid @gray-100;
        transition: @transition;

        &:hover {
            transform: translateY(-3px);
            box-shadow: @shadow-md;
        }

        .card-title {
            font-size: 1.1rem;
            color: @gray-800;
            font-weight: 600;
            margin-bottom: 1.2rem;
            padding-bottom: 0.8rem;
            border-bottom: 1px solid @gray-100;
            display: flex;
            align-items: center;

            &:before {
                content: '';
                width: 4px;
                height: 18px;
                background: @primary;
                border-radius: 2px;
                margin-right: 0.8rem;
            }
        }
    }

    .progress-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 16px;
        padding: 12px 0;
        border-radius: 12px;
        background-color: #fafafa;
    }

    .progress-item {
        display: flex;
        flex-direction: column;
        gap: 6px;
        padding: 12px 16px;
        background-color: #ffffff;
        border: 1px solid #e0e0e0;
        border-radius: 8px;
        transition: box-shadow 0.2s ease;
    }

    .progress-item:hover {
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
    }

    .item-name {
        font-size: 14px;
        color: #333;
        font-weight: 500;
    }

    .progress-wrapper {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .progress-bar-container {
        flex: 1;
        height: 10px;
        background-color: #f0f0f0;
        border-radius: 6px;
        overflow: hidden;
        position: relative;
    }

    .progress-bar {
        height: 100%;
        background-color: #4f88ff;
        border-radius: 6px;
        transition: width 0.6s ease-out;
        animation: growBar 2.5s ease-out forwards;
    }

    .progress-value {
        font-size: 13px;
        color: #555;
        min-width: 38px;
        text-align: right;
        font-family: monospace;
    }


    .risk-analysis {
        background-color: #fff;
        border-radius: 12px;
        padding: 20px;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
        border: 1px solid #f0f0f0;
    }

    .risk-list {
        display: flex;
        flex-direction: column;
        gap: 14px;
        margin-top: 16px;
    }

    .risk-item {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 14px 16px;
        border-radius: 10px;
        background-color: #fafafa;
        border-left: 6px solid transparent;
        transition: box-shadow 0.3s ease;
        position: relative;
    }

    .risk-item:hover {
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    }

    .risk-item.risk-low {
        border-color: #a5d6a7;
    }

    .risk-item.risk-medium {
        border-color: #ffd54f;
    }

    .risk-item.risk-high {
        border-color: #ef9a9a;
    }

    .point-name {
        font-size: 15px;
        font-weight: 600;
        color: #333;
    }

    .risk-level-tag {
        position: absolute;
        top: 10px;
        right: 12px;
        font-size: 12px;
        padding: 2px 6px;
        border-radius: 10px;
        font-weight: 500;
        line-height: 1;
        opacity: 0.85;
    }

    .risk-low .risk-level-tag {
        background-color: #e8f5e9;
        color: #2e7d32;
    }

    .risk-medium .risk-level-tag {
        background-color: #fff8e1;
        color: #f57f17;
    }

    .risk-high .risk-level-tag {
        background-color: #ffebee;
        color: #c62828;
    }


    .risk-indicator {
        background-color: #e0e0e0;
        border-radius: 5px;
        height: 10px;
        overflow: hidden;
        position: relative;
    }

    .risk-bar {
        height: 100%;
        background: linear-gradient(90deg, #4f88ff, #82b1ff);
        background-size: 200% auto;
        animation: smoothFlow 1.6s linear infinite;
        border-radius: 4px;
        transition: width 0.4s ease;
    }


    @keyframes moveBar {
        0% {
            background-position: 0 0;
        }

        100% {
            background-position: 40px 0;
        }
    }

    @keyframes smoothFlow {
        0% {
            background-position: 0% center;
        }

        100% {
            background-position: -200% center;
        }
    }

    .risk-percent {
        font-size: 13px;
        text-align: right;
        color: #666;
        margin-top: 4px;
        font-family: monospace;
    }


    /* 薄弱点汇总模块样式 */
    .weakness-summary {
        grid-column: 1 / -1;

        position: relative;
        overflow: hidden;
        background: #ffffff;
        border: 1px solid #e0e3ff;
        box-shadow: 0 4px 12px rgba(67, 97, 238, 0.08);
        border-radius: 10px;
        transition: all 0.3s ease;

        &:hover {
            box-shadow: 0 6px 16px rgba(67, 97, 238, 0.12);
            transform: translateY(-2px);
        }

        .summary-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1.5rem;
            padding-bottom: 0.8rem;
            border-bottom: 1px solid rgba(67, 97, 238, 0.15);

            .summary-title {
                font-size: 1.25rem;
                font-weight: 600;
                color: #1a2b6d;
                margin: 0;
                position: relative;
                padding-left: 1.8rem;

                &::before {
                    content: '';
                    position: absolute;
                    left: 0;
                    top: 50%;
                    transform: translateY(-50%);
                    width: 6px;
                    height: 24px;
                    background: linear-gradient(to bottom, #4361EE, #3A0CA3);
                    border-radius: 3px;
                }
            }

            .summary-icon {
                color: #4361EE;
                width: 40px;
                height: 40px;
                border-radius: 50%;
                background: rgba(67, 97, 238, 0.08);
                display: flex;
                align-items: center;
                justify-content: center;
                font-size: 1.2rem;
            }
        }

        .weakness-category {
            margin-bottom: 1.8rem;

            &:last-child {
                margin-bottom: 0;
            }

            .category-header {
                display: flex;
                align-items: center;
                gap: 0.8rem;
                margin-bottom: 1rem;

                i {
                    color: #4361EE;
                    font-size: 1rem;
                    width: 28px;
                    height: 28px;
                    border-radius: 50%;
                    background: rgba(67, 97, 238, 0.1);
                    display: flex;
                    align-items: center;
                    justify-content: center;
                }

                h5 {
                    font-size: 1.05rem;
                    color: #2c3e8f;
                    margin: 0;
                    font-weight: 600;
                    flex: 1;
                }

                .tag-count {
                    background: rgba(67, 97, 238, 0.1);
                    color: #4361EE;
                    font-size: 0.85rem;
                    padding: 0.2rem 0.8rem;
                    border-radius: 20px;
                    font-weight: 500;
                }
            }
        }

        .tag-list {
            display: flex;
            flex-wrap: wrap;
            gap: 0.8rem;

            .tag {
                position: relative;
                padding: 0.7rem 1.2rem;
                border-radius: 6px;
                font-size: 0.95rem;
                font-weight: 500;
                transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
                box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
                cursor: pointer;
                overflow: hidden;
                z-index: 1;
                border: 1px solid transparent;

                &::before {
                    content: '';
                    position: absolute;
                    top: 0;
                    left: 0;
                    width: 100%;
                    height: 100%;
                    background: rgba(255, 255, 255, 0.2);
                    z-index: -1;
                    transition: transform 0.5s ease;
                    transform: scaleX(0);
                    transform-origin: right;
                }

                &:hover::before {
                    transform: scaleX(1);
                    transform-origin: left;
                }

                &:hover {
                    transform: translateY(-2px);
                    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
                }

                &:active {
                    transform: translateY(0);
                }

                .tag-ping {
                    position: absolute;
                    top: -3px;
                    right: -3px;
                    width: 8px;
                    height: 8px;
                    border-radius: 50%;
                    background: #ff4757;
                    box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.7);
                    animation: ping 1.5s infinite;
                }
            }
        }

        .shared-tags .tag {
            background: rgba(67, 97, 238, 0.08);
            color: #4361EE;
            border: 1px solid rgba(67, 97, 238, 0.2);

            &:hover {
                background: rgba(67, 97, 238, 0.12);
                border-color: rgba(67, 97, 238, 0.4);
            }
        }

        .all-tags .tag {
            background: rgba(106, 130, 251, 0.08);
            color: #6a82fb;
            border: 1px solid rgba(106, 130, 251, 0.2);

            &:hover {
                background: rgba(106, 130, 251, 0.12);
                border-color: rgba(106, 130, 251, 0.4);
            }
        }

        .summary-footer {
            display: flex;
            align-items: center;
            gap: 0.6rem;
            margin-top: 1.5rem;
            padding-top: 1rem;
            border-top: 1px dashed rgba(67, 97, 238, 0.15);
            color: #6c757d;
            font-size: 0.85rem;
            font-weight: 500;

            i {
                font-size: 1rem;
                color: #4361EE;
            }
        }

        @keyframes ping {
            0% {
                transform: scale(0.8);
                box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.7);
            }

            70% {
                transform: scale(1);
                box-shadow: 0 0 0 8px rgba(255, 71, 87, 0);
            }

            100% {
                transform: scale(0.8);
                box-shadow: 0 0 0 0 rgba(255, 71, 87, 0);
            }
        }
    }









    @keyframes ping {
        0% {
            transform: scale(0.8);
            box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.7);
        }

        70% {
            transform: scale(1);
            box-shadow: 0 0 0 8px rgba(255, 71, 87, 0);
        }

        100% {
            transform: scale(0.8);
            box-shadow: 0 0 0 0 rgba(255, 71, 87, 0);
        }
    }
}

/* AI建议与结论样式 */
.ai-suggestions {
    .suggestion-card {
        background: #ffffff;
        border-radius: 12px;
        margin-bottom: 1.8rem;
        overflow: hidden;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
        border: 1px solid #e9ecef;
        transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
        position: relative;

        &:hover {
            transform: translateY(-5px);
            box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
        }

        &:last-child {
            margin-bottom: 0;
        }

        .card-header {
            background: linear-gradient(135deg, #1a2b6d, #3A0CA3);
            padding: 1.2rem 1.8rem;
            display: flex;
            align-items: center;
            gap: 1rem;
            position: relative;
            overflow: hidden;

            &::before {
                content: '';
                position: absolute;
                top: -50%;
                right: -50%;
                width: 200%;
                height: 200%;
                background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 70%);
                pointer-events: none;
            }

            i {
                color: white;
                font-size: 1.3rem;
                width: 36px;
                height: 36px;
                border-radius: 50%;
                background: rgba(255, 255, 255, 0.15);
                display: flex;
                align-items: center;
                justify-content: center;
                z-index: 2;
            }

            .card-title {
                margin: 0;
                color: white;
                font-weight: 600;
                font-size: 1.15rem;
                letter-spacing: 0.3px;
                z-index: 2;
                position: relative;

                &::after {
                    content: '';
                    position: absolute;
                    bottom: -5px;
                    left: 0;
                    width: 40px;
                    height: 2px;
                    background: rgba(255, 255, 255, 0.5);
                }
            }
        }

        .card-body {
            padding: 1.8rem;
            background: #f8f9fa;
            position: relative;

            p {
                margin: 0;
                color: #343a40;
                line-height: 1.8;
                font-size: 1rem;
                position: relative;
                z-index: 2;
            }

            .recommended-points {
                display: flex;
                flex-direction: column;
                gap: 1rem;
                position: relative;
                z-index: 2;

                .recommended-point {
                    display: flex;
                    align-items: flex-start;
                    gap: 1rem;
                    background: white;
                    padding: 1.2rem;
                    border-radius: 8px;
                    border-left: 4px solid #4361EE;
                    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
                    transition: all 0.3s ease;
                    position: relative;
                    overflow: hidden;

                    &::before {
                        content: '';
                        position: absolute;
                        top: 0;
                        left: 0;
                        width: 100%;
                        height: 100%;
                        background: linear-gradient(90deg, rgba(67, 97, 238, 0.03) 0%, rgba(67, 97, 238, 0) 100%);
                        z-index: 1;
                    }

                    &:hover {
                        transform: translateX(5px);
                        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
                        border-left-color: #3A0CA3;
                    }
                }

                .point-index {
                    width: 28px;
                    height: 28px;
                    background: linear-gradient(135deg, #4361EE, #3A0CA3);
                    color: white;
                    border-radius: 50%;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    font-size: 0.9rem;
                    font-weight: 700;
                    flex-shrink: 0;
                    margin-top: 2px;
                    z-index: 2;
                }

                .point-name {
                    color: #212529;
                    font-size: 1rem;
                    line-height: 1.6;
                    font-weight: 500;
                    z-index: 2;
                }
            }

            // 添加微妙的背景图案
            &::before {
                content: "";
                position: absolute;
                bottom: 0;
                right: 0;
                width: 120px;
                height: 120px;
                background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%234361ee' fill-opacity='0.03' fill-rule='evenodd'%3E%3Cpath d='M0 40L40 0H20L0 20M40 40V20L20 40'/%3E%3C/g%3E%3C/svg%3E");
                z-index: 1;
                opacity: 0.7;
            }
        }

        // 系统总结结论卡片特殊样式
        &:nth-child(1) .card-header {
            background: linear-gradient(135deg, #1a2b6d, #3A0CA3);
        }

        // 教学建议卡片特殊样式
        &:nth-child(2) .card-header {
            background: linear-gradient(135deg, #0d6e72, #1A7F75);
        }

        // 推荐知识点卡片特殊样式
        &:nth-child(3) .card-header {
            background: linear-gradient(135deg, #6a11cb, #2575fc);
        }
    }
}

.modal-footer {
    padding: 1.2rem 1.5rem;
    border-top: 1px solid @gray-200;
    display: flex;
    justify-content: flex-end;
    gap: 0.8rem;
    background: white;

    .btn {
        padding: 0.8rem 1.5rem;
        border-radius: @radius-sm;
        font-size: 0.95rem;
        font-weight: 500;
        cursor: pointer;
        transition: @transition;
        border: none;
        display: flex;
        align-items: center;
        gap: 0.5rem;
        box-shadow: @shadow-sm;

        &.btn-primary {
            background-color: @gray-100;
            color: @gray-700;
            border: 1px solid @gray-300;

            &:hover {
                background-color: @gray-200;
                transform: translateY(-2px);
            }
        }

        &.btn-secondary {
            background: linear-gradient(to right, @primary, @secondary);
            color: white;

            &:hover {
                background: linear-gradient(to right, lighten(@primary, 5%), lighten(@secondary, 5%));
                transform: translateY(-2px);
                box-shadow: @shadow-md;
            }

            &:disabled {
                opacity: 0.6;
                cursor: not-allowed;
                transform: none;
                background: @gray-400;
            }
        }
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);

    }

    to {
        opacity: 1;
        transform: translateY(0);

    }
}

@keyframes growBar {
    from {
        width: 0%;
    }

    to {
        width: var(--target-width);
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@media (max-width: 768px) {
    .modal-container {
        width: 95%;
    }

    .analysis-grid {
        grid-template-columns: 1fr;
    }

    .performance-stats {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 576px) {
    .modal-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.8rem;

        .analysis-meta {
            position: static;
            transform: none;
            flex-wrap: wrap;
        }

        .close-btn {
            position: absolute;
            top: 1rem;
            right: 1rem;
        }
    }

    .modal-body {
        padding: 1rem;
    }

    .section {
        padding: 1.2rem;
    }

    .overview-cards {
        grid-template-columns: 1fr;
    }

    .modal-footer {
        flex-direction: column;

        .btn {
            width: 100%;
            justify-content: center;
        }
    }
}
</style>